<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>基础知识</title>
	<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"" rel="stylesheet">
	<link href="https://cdn.bootcdn.net/ajax/libs/animate.css/3.2.3/animate.css" rel="stylesheet">
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="../../static/css/public.css" />
	<style type="text/css">
		li{
			text-indent: 2em;
			padding: 5px 0;
		}
	</style>
</head>
<body>
	<!-- 回到顶部 -->
	<div class="topBtn">
		<a href="#top">
			<i class="fa fa-long-arrow-up"></i>
		</a>
	</div>
	<!--右边内容-->
	<div id="app" class="main animated fadeInRight">
		<div class="shadow">
			<div class="Table" v-cloak id="top">
				<div class="TableRow" v-for="(el,index) in list">
					<a class="RowLeft" :href="'#'+el.id"
					:title="el.name"
					>{{el.name}}</a>
					<span class="RowRight">{{el.explain}}</span>
				</div>
			</div>
			<div>
				<h4 id="use">关于svg.js</h4>
				<p>
					svg.js是一个轻量的svg封装插件，将svg常用的方法封装，而且还支持插件扩展。
					使用简单，支持链式写法。
					地址:<a href="https://svgjs.com/docs/3.0/#svg-js" target="_blank">
						https://svgjs.com/docs/3.0/#svg-js</a>。
				</p>
				<div style="margin-bottom: 15px;">NPM使用方式：npm install @svgdotjs/svg.js</div>
				<div>CDN使用方式：https://cdnjs.com/libraries/svg.js</div>
				<div>CDN使用方式：https://cdn.jsdelivr.net/npm/@svgdotjs/svg.js</div>
				<div>CDN使用方式：https://unpkg.com/@svgdotjs/svg.js</div>
			</div>
			<div>
				<h4 id="support">检测浏览器是否支持SVG</h4>
				<p>
					默然情况下，svg.js假设客户端浏览器支持SVG，你也可以测试浏览器是否支持SVG
				</p>
				<pre>
	if (SVG.supported) {
	  var draw = SVG('drawing')
	  var rect = draw.rect(100, 100)
	} else {
	  alert('SVG not supported')
	}				
				</pre>
			</div>
			<div>
				<h4 id="new">新建画布</h4>
				<pre>
	//若是NPM:import { SVG } from '@svgdotjs/svg.js'
	var draw = SVG('svg1').size(300, 300);=>设置300*300的画布
	var circle = draw.circle(50);=>画一个半径50的圆，并移动到(10,10)处
	circle.fill('red').move(10, 10);	
	//设置属性，类名，id	
	circle.attr({
		fill: '#f06', 'fill-opacity': 0.5, 
		stroke: '#000', 'stroke-width': 10
	})	
	circle.attr({ x: 50, y: 40 })	=>将圆重新移动位置
	circle.radius(10) => 圆半径
	circle.addClass('circle');//添加类 
	// 其他方法:element.classes()、element.hasClass('purple-rain')、element.removeClass('pink-flower')、element.toggleClass('pink-flower')
	circle.id('circle');//设置ID
				</pre>
			</div>
			<div>
				<h4 id="handle">操作元素</h4>
				<pre>
	var rect = draw.rect(100, 100)
	var group = draw.group()
	group.add(rect) //-> returns group
	rect.addTo(group) //-> returns rect
	
	var clone = rect.clone()//复制
	rect.remove()	//移除
	rect.clear()	//彻底清除
	rect.replace(draw.circle(100))
	rect.toParent(group) // looks the same as before
	
	//操作rect顺序
	rect.after(circle)
	rect.before(circle)
	rect.insertAfter(circle)
	rect.insertBefore(circle)
	
	rect.next()//获取rect下一个元素
	rect.position()//Get the position (a number) of rect between its siblings
	rect.previous()//Get the previous sibling
	rect.siblings()//To get all siblings of rect, including rect itself
	
	var point = path.point(e.pageX, e.pageY) // {x, y}
	
				</pre>
			</div>
			<div>
				<h4 id="Nested">嵌套SVG</h4>
				<pre>
	var nested = draw.nested()
	var rect = nested.rect(200, 200)
	//returns: SVG.Nested				
	JavaScript继承堆栈:SVG.Nested &lt; SVG.Container &lt; SVG.Parent		
				</pre>
			</div>
		</div>
	</div>
	<!--页面加载进度条-->
	<script src="https://cdn.bootcdn.net/ajax/libs/pace/0.5.0/pace.min.js"></script>
	<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.5.17/vue.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var app = new Vue({
			el: "#app",
			data: function() {
				return {
					list: [
						{ name: "关于svg.js",id: "use",explain: ''},
						{ name: "检测浏览器是否支持",id: "support",explain: ''},
						{ name: "新建画布",id: "new",explain: ''},
						{ name: "操作元素",id: "handle",explain: ''},
						{ name: "嵌套SVG",id: "Nested",explain: ''},
					]
				}
			}
		})
	</script>
</body>

</html>